const E = window.wangEditor
const editor = new E("#myeditor")
var Main = {
    data() {
        return {
            textarea1: "",
            form: {
                content: '',
                pid: 0,
            }
        }
    },
    mounted() {
        this.initWindow();
    },
    methods: {
        initWindow() {
            const SINA_URL_PATH = "https://lf3-cdn-tos.bytescm.com/obj/static/xitu_juejin_web/img"

            editor.config.menus = [
                'emoticon',
                'image',
                'link',
            ]
            editor.config.height = 100
            // 或者 const editor = new E(document.getElementById('div1'))
            editor.create()
        },sendComment() {
            let that = this;
            if (this.form.accound == '' || this.form.usercard == '' || this.form.password == '') {
                this.$message({
                    message: '请填写完整',
                    type: 'warning'
                });
            } else {
                axios({
                        method: "post",
                        url: "/send",
                        // headers:{"Content-Type":'application/x-www-form-urlencoded;charset=UTF-8','X-Requested-With': 'XMLHttpRequest'},
                        data: {
                            content: editor.txt.html(),
                            pid: $('#data-oodnjppm').val()
                        }
                    })
                    .then(function (res) {
                        //接口成功返回结果执行
                        console.log(res.status);
                        console.log(res);
                        if (res.status == 200 && res.data.code == '200') {
                            that.$message({
                                message: '评论成功',
                                type: 'success'
                            });
                            location.reload();
                        } else {
                            that.$message.error(res.data.msg);
                        }
                    })
                    .catch(function (err) {})
            }
        }
    }
}
var Ctor = Vue.extend(Main)
new Ctor().$mount('#app')